<template>
    <div class="my-counter">
        <!-- 
        1、绑定数量增加和减少点击事件
        2、数量减少时需要注意数量不能低于1，低于1 就给button设置disabled
        3、给输入框绑定失焦事件，数量不能低于1
      -->
        <button type="button" class="btn btn-light" @click="obj.goods_count--" :disabled="obj.goods_count<=1">-</button>
        <input type="number" class="form-control inp" v-model="obj.goods_count" @blur="changeCount">
        <button type="button" class="btn btn-light" @click="obj.goods_count++">+</button>
    </div>
</template>

<script>
export default {
    props: {
        obj: Object,
    },
    methods: {
        changeCount() {
            if (this.obj.goods_count < 1) this.obj.goods_count = 1
        },
    },
}
</script>

<style lang="less" scoped>
.my-counter {
    display: flex;
    .inp {
        width: 45px;
        text-align: center;
        margin: 0 10px;
    }
    .btn,
    .inp {
        transform: scale(0.9);
    }
}
</style>